package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        //无参构造器
        Class cls = Class.forName("reflect.Student");
        Object obj = cls.newInstance();
        System.out.println(obj);


        //有参构造器
        Constructor c = cls.getConstructor(String.class, int.class, char.class);
        Object obj1 = c.newInstance("张三", 18, '男');
        System.out.println(obj1);

    }
}
